import {request} from '@utils/http';
import { Departments, DictItem, DoctorItem, ReqGetDoctorParams, ReqGetHospitalDetailResponse, ReqGetHospitalListParams, ReqGetHospitalListResponse, ReqGetScheduleParams, ReqGetScheduleResponse } from './types';

/**
 * 请求获取省份信息的函数封装 
 */
export function reqGetProvince(){
  return request.get<any, DictItem[]>('/admin/cmn/dict/findByDictCode/province');
}


/**
 * 请求获取城市或者区县
 */
export function reqGetCitiesOrDistrict(parentId: number){
  return request.get<any, DictItem[]>(`/admin/cmn/dict/findByParentId/${parentId}`);
}

/**
 * 请求获取医院等级信息 
 */
export function reqGetHosTypes(){
  return request.get<any, DictItem[]>('/admin/cmn/dict/findByDictCode/hostype');
}

/**
 * 请求医院的列表数据
 */
export function reqGetHospitalList({page, limit, ...args}: ReqGetHospitalListParams){
  return request.get<any, ReqGetHospitalListResponse>(`/admin/hosp/hospital/${page}/${limit}`, {
    //设置查询字符串
    params: args
  });
}

/**
 * 请求获取医院的科室
 */
export function reqGetDepartments(hoscode: string){
  return request.get<any, Departments>(`/admin/hosp/department/${hoscode}`);
}

/**
 * 获取医院某个科室的排班信息
 */
export function reqGetHospitalSchedule({page, limit, hoscode, depcode}:ReqGetScheduleParams){
  return request.get<any, ReqGetScheduleResponse>(`/admin/hosp/schedule/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`);
}
/**
 * 获取某一天排班医生的信息
 */
export function reqGetDoctors({workDate, depcode, hoscode}: ReqGetDoctorParams){
  return request.get<any, DoctorItem[]>(`/admin/hosp/schedule/findScheduleList/${hoscode}/${depcode}/${workDate}`);
}


/**
 * 获取医院详情
 */
export function reqGetHospitalDetail(hosid: string){
  return request.get<any, ReqGetHospitalDetailResponse>(`/admin/hosp/hospital/show/${hosid}`);
}

/**
 * 更新医院的上下线情况
 */
export function reqUpdateHospitalStatus(id: string, status: number){
  return request.get<any, null>(`/admin/hosp/hospital/updateStatus/${id}/${status}`);
}